<?php
/**
 * Created by PhpStorm.
 * User: mhx
 * 这部分为各种小网站的数据
 *
 */

class HandlehtmlController extends baseController{
    protected static $Folder_arr = array();
    protected static $Citynames = array();
    protected static $mFilePath = '';
    protected static $debug = '';
    public function __construct()
    {
        parent::__construct();
        self::$debug = false;
        self::$mFilePath = ROOT_PATH.'upload/';
        self::$Folder_arr = array(
            'www.redbrickartmuseum.com' => '0',
            'museum.cafa.com.cn' => '1',
            'tjart.orgcc.com' => '2',
            'www.timesartmuseum.com' => '3',
            'www.ssmuseum.cn' => '4',
            'www.zfjmsg.com' => '5',
            'www.ccqag.org' => '6',
            'www.hopeartmuseum.com' => '7',
            'www.gdmoa.org' => '8',
            'www.hxnart.com' => '9',
            'www.szam.org' => '10',
            'www.sjzmsg.cn' => '11',
            'www.zzmsg.cn' => '12',
            'www.hbmoa.com' => '13',
            'www.wuhanam.com' => '14',
            'www.hn-cfmsg.com' => '15',
            'www.jsmsg.com' => '16',
            'www.njshuhuayuan.com' => '17',
            'www.zan8.cn' => '18',
            'www.liuhaisu.org' => '19',
            'www.jingdezhenartmuseum.org' => '20',
            'www.dlzsmsg.com' => '21',
            'www.lnmuseum.com.cn' => '22',
            'www.duolunmoma.org' => '23',
            'www.haipai-museum.cn' => '24',
            'www.rockbundartmuseum.org' => '25',
            'www.qdmjmsg.com' => '26',
            'www.tymsg.org.cn' => '27',
            'www.zjam.org.cn' => '28',
            'www.sanshang-art.com' => '29',
            'www.mcacaa.org' => '30',
            'www.yide-art.com' => '31',
            'www.nma.org.cn' => '32',
            'www.kdmofa.tnua.edu.tw' => '33',
        );
        self::$Citynames = array(
            '北京',
            '上海',
            '广州',
            '深圳',
            '成都',
            '武汉',
            '杭州',
            '重庆',
            '郑州',
            '南京',
            '西安',
            '苏州',
            '天津',
            '长沙',
            '福州',
            '沈阳',
            '济南',
            '温州',
            '合肥',
            '哈尔滨',
        );
    }

    public function index(){
        //set_time_limit(60*60*8);

        vendor('phpQuery.phpQuery');
        //echo '123';die;
        /*$Controller = A('Home/Doubancity');
        $Controller->getContent();*/
        //页面下

        $url_0 = array(
            'http://www.redbrickartmuseum.com/cn/exhibition/showlist',//6    0
            'http://museum.cafa.com.cn/cn/upcoming',//8  0
            'http://museum.cafa.com.cn/cn/current',
            'http://tjart.orgcc.com/zhanlan/mlist.html',//9 0
            'http://www.timesartmuseum.com/cn/show.php',//11    0
            'http://www.ssmuseum.cn/a/exhibitions/it_exhibition/',//15     0
            'http://www.ssmuseum.cn/a/exhibitions/up_exhibitions/',      //0
            'http://www.zfjmsg.com/exhibit.html',//19    0
            'http://www.ccqag.org/pod_news.html',//21  0
            'http://www.hopeartmuseum.com/index.php?c=list&cs=dangqianzhanlan&',//23  0
            'http://www.hopeartmuseum.com/index.php?c=list&cs=zhanlanyugao&',   //0
            'http://www.gdmoa.org/home/Exhibition_information/',//27   0
            'http://www.hxnart.com/main.aspx?ModuleNo=04&SubModuleNo=0401',//28 0
            'http://www.hxnart.com/main.aspx?ModuleNo=04&SubModuleNo=0402',//28  0
            'http://www.szam.org/exhibit/list.aspx?f=0',//29     0
            'http://www.szam.org/exhibit/list.aspx?f=1',//29     0
            'http://www.sjzmsg.cn/a/zl/zzzl/',//35    0
            'http://www.sjzmsg.cn/a/zl/zlyg/',//35    0
            'http://www.zzmsg.cn/articlelist.aspx?pageid=27',//36   0
            'http://www.zzmsg.cn/articlelist.aspx?pageid=26',//36   0
            'http://www.zzmsg.cn/articlelist.aspx?pageid=28',//36    0
            'http://www.hbmoa.com/index.php/index-show-tid-6.html',//41  0
            'http://www.hbmoa.com/index.php/index-show-tid-7.html',    //0
            'http://www.wuhanam.com/content.aspx?node=712',//44    0
            'http://www.wuhanam.com/content.aspx?node=713',//44    0
            'http://www.hn-cfmsg.com/news.php?lb=4',//46   0
            'http://www.jsmsg.com/news/zlxx//list.shtml',//48   0
            'http://www.jsmsg.com/news/zlyg//list.shtml',//48   0
            'http://www.njshuhuayuan.com/index.php/News/news1',//49   0
            'http://www.zan8.cn/html/yugao.html',//51     0
            'http://www.liuhaisu.org/zl.asp',//52   0
            'http://www.liuhaisu.org/zl_yg.asp',//52   0
            //'http://www.jingdezhenartmuseum.org/news_more.asp?lm=54',//55  0这个网站比较难链接服务器不行
            //'http://www.jingdezhenartmuseum.org/news_more.asp?lm=55',//55   0
            'http://www.dlzsmsg.com/index.php?c=Exhibition&a=Index&m=1',//57   0
            'http://www.dlzsmsg.com/index.php?c=Exhibition&a=Index&m=2',//57    0
            'http://www.lnmuseum.com.cn/news/?ChannelID=431',//59   0
            'http://www.lnmuseum.com.cn/news/?ChannelID=432',//59   0
            'http://www.duolunmoma.org/exhibitions_&_events/current.html',//64   0
            'http://www.duolunmoma.org/exhibitions_&_events/upcoming.html',//64   0
            //'http://www.haipai-museum.cn/information/list.php?ctype=1',//65  0
            //'http://www.haipai-museum.cn/information/list.php?ctype=2',//65   0
            'http://www.rockbundartmuseum.org/cn/exhibition/show_list/',//67    0
            //'http://www.qdmjmsg.com/zhanlan.aspx?sid=1',//70   0
            //'http://www.qdmjmsg.com/zhanlan.aspx?sid=2',//70   0
            'http://www.tymsg.org.cn/index.php/jinqizhanlan/',//72     0
            'http://www.zjam.org.cn/Site/Exbition/ExbitionList.aspx?type=1',//73    0
            'http://www.zjam.org.cn/Site/Exbition/ExbitionList.aspx?type=2',//73    0
            //'http://www.sanshang-art.com/sanshang/',//74   0
            'http://www.mcacaa.org/index.php?ac=article&at=list&tid=13',//75   0
            'http://www.mcacaa.org/index.php?ac=article&at=list&tid=15',//75   0
            //'http://www.yide-art.com/5703-3288/11487.html',//76    0
            //'http://www.yide-art.com/5704-3288/11489.html',//76    0
            'http://www.nma.org.cn/exhibition/page-1.html',//77   0
            'http://www.kdmofa.tnua.edu.tw/index.php?REQUEST_ID=bW9kPWV4'//82   0
        );

        $url_1 = array(
            'http://www.wanfung.com.cn/jt/yfzl.asp',//7       1
            'http://www.wanfung.com.cn/jt/yfzl_zlyg.asp',//7    1
            'http://new.daqiangallery.com.cn/artspace/daqian',//20 1
            'http://www.gdgc-art.com/cn_asp/exhibition.asp?typeid=38',//31   1
            'http://www.gdgc-art.com/cn_asp/exhibition.asp?typeid=39',//31   1
            'http://www.hebhy.cn/NewsList.asp?SortID=35',//34   1
            'http://www.hxam.net/exhibition/current.html',//37   1
            'http://www.orgcc.com/exhibit/list2.html',//60   1
            'http://www.orgcc.com/exhibit/list1.html',//60   1
            'http://www.hanartmuseum.org/Art/portal/exhibitionlist.html?locale=zh_CN&id=16',//66   1
            'http://www.hanartmuseum.org/Art/portal/exhibitionlist.html?locale=zh_CN&id=18',//66    1
        );

        $url_ajax = array(
            'http://ucca.org.cn/exhibitions/exhibitions-current/',//5    ajax
            'http://ucca.org.cn/exhibitions/exhibitions-upcoming/',//5    ajax
            'http://www.enjoy798.com/zllist.asp?bid=1',//16  ajax table
            'http://www.enjoy798.com/zllist.asp?bid=2',//16  ajax table
            'http://www.gsyart.com/show_index.php',//26   安全狗
            'http://www.deshengart.com/exhibition.asp',//30  table
            'http://www.mam.gov.mo/c/exhibition',//79   ajax table
            'http://www.mam.gov.mo/c/exhibition_future',//79  ajax table
            'http://www.tfam.museum/Exhibition/Exhibition.aspx?ddlLang=zh-tw',//81    ajax
            'http://www.tfam.museum/Exhibition/ExhibitionNew.aspx?ddlLang=zh-tw',//81   ajax
        );


        /*//美术馆爬取
        $Controller = A('Home/MuseumCrawler');
        $Controller->getContent();*/

        $Controller = A('Home/Tangwest');
        $Controller->getContent();


        $try = A('Home/Webdownload');
        //$try = new WebDownload();
        $temp_i = 0;
        $path = '';
        if(!is_dir(ROOT_PATH.'/DownloadHtml'))mkdir(ROOT_PATH.'/DownloadHtml');

//test  1page
        /*$urlq = 'http://www.deshengart.com/exhibition.asp';
        $path = explode('/',$urlq)[2];
        if(!is_dir(MYROOT_PATH.'/'.$path)?mkdir($path = MYROOT_PATH.'/'.$path):$path = MYROOT_PATH.'/'.$path);
        $try->download($urlq,$path);
        exit;*/
//test allpage

        $filename_0 = array();
        while(isset($url_0[$temp_i])){
            $path = explode('/',$url_0[$temp_i])[2];

            if(!is_dir(ROOT_PATH.'/DownloadHtml'.'/'.$path)?mkdir($path = ROOT_PATH.'/DownloadHtml'.'/'.$path):$path = ROOT_PATH.'/DownloadHtml'.'/'.$path);
            $filename_0[$url_0[$temp_i]] = $try->download($url_0[$temp_i],$path);
            ++$temp_i;
            $path = '';
        }
        $handle = A('Home/Handlehtml');
        $handle->handle($filename_0);

        return '';
        exit;
        $temp_i = 0;
        while(isset($url_1[$temp_i])){
            $path = explode('/',$url_1[$temp_i])[2];
            if(!is_dir(MYROOT_PATH.'/'.$path)?mkdir($path = MYROOT_PATH.'/'.$path):$path = MYROOT_PATH.'/'.$path);
            $filename_0[$url_1[$temp_i]] = $try->download($url_1[$temp_i],$path);
            ++$temp_i;
            $path = '';
        }
        $temp_i = 0;
        while(isset($url_ajax[$temp_i])){
            $path = explode('/',$url_ajax[$temp_i])[2];
            if(!is_dir(MYROOT_PATH.'/'.$path)?mkdir($path = MYROOT_PATH.'/'.$path):$path = MYROOT_PATH.'/'.$path);
            $filename_0[$url_ajax[$temp_i]] = $try->download($url_ajax[$temp_i],$path);
            ++$temp_i;
            $path = '';
        }




        exit;
        $filename_0 = array();
//单页
        $temp_i = 0;
        while(isset($url_0[$temp_i])){
            $path = explode('/',$url_0[$temp_i])[2];
            if(!is_dir(MYROOT_PATH.'/'.$path)?mkdir($path = MYROOT_PATH.'/'.$path):$path = MYROOT_PATH.'/'.$path);
            $filename_0[$url_0[$temp_i]] = $try->download($url_0[$temp_i],$path);
            ++$temp_i;
        }
//多页
        $temp_i = 0;
        $filename_1 = array();
        while(isset($url_1[$temp_i])){
            $key = explode('.',$url_1[$temp_i])[1];
            $filename_1[$url_1[$temp_i]] = $key;
            ++$temp_i;
        }

        $temp_i = 0;
        $filename_ajax = array();
        while(isset($url_ajax[$temp_i])){
            $key = explode('.',$url_ajax[$temp_i])[1];
            $filename_ajax[$url_ajax[$temp_i]] = $key;
            ++$temp_i;
        }
    }



    public function handle($url){
        //下载页面$url是键值对的形式键为下载页面的url，值为下载下来以后存储的名字
        //var_dump($url);die;
        //得到键值对里的所有值
        //var_dump($url);die;
        $temp_values = array_values($url);

        $temp_i = 0;
        $temp_key = '';
        $temp_keys = array();
//每次循环读取名字
//获得文件夹名
        while(isset($temp_values[$temp_i])){
            $temp_key = array_keys($url,$temp_values[$temp_i])[0];
            $temp_key = explode('/',$temp_key)[2];
            array_push($temp_keys,$temp_key);
            $temp_key = array();
            ++$temp_i;
            /*    $i = 0;
                //echo !in_array($temp_key,$temp_keys);die;
                if(!in_array($temp_onekey,$temp_keys)){
                    //$temp_key[0] =  $temp_values[$temp_i];
                    array_push($temp_key,$temp_values[$temp_i]);
                    //echo $temp_key;die;
                    //var_dump($temp_key);die;
                    array_push($temp_keys[$temp_onekey][],$temp_key[0]);
                    //$temp_keys[]=$temp_key[0];
                    var_dump($temp_keys);die;
                }else{
                    $temp_keys[$temp_onekey][] = $temp_values[$temp_i];
                }
                var_dump($temp_keys);die;*/
        }
        $path = ROOT_PATH.'Downloadhtml';
        $temp_i = 0;
        //var_dump($temp_keys);die;
        while(isset($temp_keys[$temp_i])){
            if(!is_dir($path.'/'.$temp_keys[$temp_i])){
                continue;
            }else{
                /*$fun = 'fun'.self::$Folder_arr[$temp_keys[$temp_i]];
                $this->$fun($temp_keys[$temp_i],$path.'/'.$temp_keys[$temp_i],$temp_values);*/
                $this->getDetailsUrl($temp_keys[$temp_i],$path.'/'.$temp_keys[$temp_i],$temp_values);
            }
            ++$temp_i;
        }
    }

    protected function getDetailsUrl($url,$path,$filename){

        /* var_dump($url);
         echo '<br />';
         var_dump($path);
         echo '<br />';
         var_dump($filename);
         die;*/
        //$url 主页
        //$path 主文件名
        //$filename 操作文件名
        $tagsall = array(
            'www.redbrickartmuseum.com' => '/cn/exhibition/detail',
            'museum.cafa.com.cn' => '/cn/Exhibitions/',
            'tjart.orgcc.com' => '/zhanlan/',
            'www.timesartmuseum.com' => 'show_info.php?id',
            'www.ssmuseum.cn' => '/a/exhibitions/it_exhibition/',
            'www.zfjmsg.com' => '/exhibit/',
            'www.ccqag.org' => '/pod_news-',
            'www.hopeartmuseum.com' => 'index.php?c=msg&amp;id',
            'www.gdmoa.org' => '/home/Exhibition_information/Exhibition_',
            'www.hxnart.com' => 'exhibition/niandu.aspx?SubModuleNo=',
            'www.szam.org' => '/exhibit/detail.aspx?exb_id',
            'www.sjzmsg.cn' => '/a/20',
            'www.zzmsg.cn' => 'Artshow.aspx?pageid',
            'www.hbmoa.com' => '/index.php/index-view-aid-',
            'www.wuhanam.com' => '/detail.aspx?node=713&id=',
            'www.hn-cfmsg.com' => 'news/',
            'www.jsmsg.com' => '/news/zlxx/20',
            'www.njshuhuayuan.com' => '/index.php/News/newslisthy/id/',
            'www.zan8.cn' => '/html/yszx/zlhd/',
            'www.liuhaisu.org' => 'zl_yg_view.asp?id=',
            'www.jingdezhenartmuseum.org' => 'mahongxue',//空服务器不行连不上
            'www.dlzsmsg.com' => '/index.php?c=Exhibition&a=View&m=1&id',
            'www.lnmuseum.com.cn' => 'index.asp?ChannelID=',
            'www.duolunmoma.org' => '../exhibitions_&_events/',
            'www.haipai-museum.cn' => 'mahongxue',//不更新了
            'www.rockbundartmuseum.org' => '/cn/exhibition/overview/',
            'www.qdmjmsg.com' => 'mahongxue',//这网站太假了2014年往后都不更新了
            'www.tymsg.org.cn' => '/index.php/jinqizhanlan/20',
            'www.zjam.org.cn' => 'ExbitionDetail.aspx?etid=',
            'www.sanshang-art.com' => 'mahongxue',//这网站脑残一样
            'www.mcacaa.org' => '/index.php?ac=article&amp;at=read&amp;did',
            'www.yide-art.com' => 'mahongxue',//这网站玩呢
            'www.nma.org.cn' => '/article/20',
            'www.kdmofa.tnua.edu.tw' => 'index.php?REQUEST_ID=bW9kPWV4JnBhZ2U9ZGV0YWlsJllZPTIwMTYmRUlEPTI',
        );
        $controllerall = array(
            'www.redbrickartmuseum.com' => 'Redbri',
            'museum.cafa.com.cn' => 'Mcafac',
            'tjart.orgcc.com' => 'Tjarto',
            'www.timesartmuseum.com' => 'Timesa',
            'www.ssmuseum.cn' => 'Ssmuse',
            'www.zfjmsg.com' => 'Zfjmsg',
            'www.ccqag.org' => 'Ccqago',
            'www.hopeartmuseum.com' => 'Hopear',
            'www.gdmoa.org' => 'Gdmoao',
            'www.hxnart.com' => 'Hxnart',
            'www.szam.org' => 'Szamor',
            'www.sjzmsg.cn' => 'Sjzmsg',
            'www.zzmsg.cn' => 'Zzmsgc',
            'www.hbmoa.com' => 'Hbmoac',
            'www.wuhanam.com' => 'Wuhana',
            'www.hn-cfmsg.com' => 'Hucfms',
            'www.jsmsg.com' => 'Jsmsgc',
            'www.njshuhuayuan.com' => 'Njshuh',
            'www.zan8.cn' => 'Zan8cn',
            'www.liuhaisu.org' => 'Liuhai',
            'www.jingdezhenartmuseum.org' => 'Jingde',
            'www.dlzsmsg.com' => 'Dlzsms',
            'www.lnmuseum.com.cn' => 'Lnmuse',
            'www.duolunmoma.org' => 'Duolun',
            'www.haipai-museum.cn' => 'Haipai',
            'www.rockbundartmuseum.org' => 'Rockbu',
            'www.qdmjmsg.com' => 'Qdmjms',
            'www.tymsg.org.cn' => 'Tymsgc',
            'www.zjam.org.cn' => 'Zjamor',
            'www.sanshang-art.com' => 'Sansha',
            'www.mcacaa.org' => 'Mcacaa',
            'www.yide-art.com' => 'Yidear',
            'www.nma.org.cn' => 'Nmaorg',
            'www.kdmofa.tnua.edu.tw' => 'Kdmofa',
        );
        $tags = $tagsall[$url];

        $testnumber = 0;
        if($url =='museum.cafa.com.cn'){
            $testnumber = 0;
            //echo 'contets:::',$contents,'<br />';
        }else{
            $testnumber = 0;
        }


        //判断日期文件夹
        if(!is_dir($path.'/'.date('Y_m_d'))){
            if(!is_dir($path.'/'.date('Y_m_d',strtotime("-1 day")))){
                if(!is_dir($path.'/'.date('Y_m_d',strtotime("+1 day")))){
                    return false;
                }else{
                    $path = $path.'/'.date('Y_m_d',strtotime("+1 day"));
                }
            }else{
                $path = $path.'/'.date('Y_m_d',strtotime("-1 day"));
            }
        }else{
            $path = $path.'/'.date('Y_m_d');
        }

        //echo $path;die;
        //分析不变的默认没有
        //分析加/数组
        $urlplugin_1  = array('7','9','12','15','19','33');
        //分析加/cn/数组
        $urlplugin_2  = array('3');
        //分析加/news/
        $urlplugin_3 = array('22');
        //浙江美术馆脑残一样加了个/Site/Exbition/
        $urlplugin_4 = array('28');

        $temp_i = 0;
        $urllist = array();
        $urllist_i = 0;

        while(isset($filename[$temp_i])){
            if(!file_exists($path.'/'.$filename[$temp_i])){
                ++$temp_i;
                continue;
            }else{
                $contents = file_get_contents($path.'/'.$filename[$temp_i]);

                if($testnumber ==1){
                    echo '<br />',$path.'/'.$filename[$temp_i],'<br />';

                    //echo 'contets:::',$contents,'<br />';
                }

                $pos = 0;
                $urllist_i_i = 0;
                while($pos !== false) {
                    $pos = mb_strpos($contents, $tags);
                    $contents = mb_substr($contents,$pos);
                    $pos = mb_strpos($contents,'"');
                    $url_details = strip_tags(mb_substr($contents,0,$pos));

                    $pos_check = mb_strpos($url_details,'>');
                    if($pos_check != false){
                        $url_details = mb_substr($url_details,0,$pos_check);
                    }
                    $pos_check = mb_strpos($url_details,"'");
                    if($pos_check != false){
                        $url_details = mb_substr($url_details,0,$pos_check);
                    }
                    $pos_check = mb_strpos($url_details,'<');
                    if($pos_check != false){
                        $url_details = mb_substr($url_details,0,$pos_check);
                    }


                    if($testnumber == 1){
                        echo '<br />','url_details!!!:',$url_details,'<br />';
                    }



                    //分析加/
                    if(in_array(self::$Folder_arr[$url],$urlplugin_1)){
                        $urllist[$urllist_i][$urllist_i_i] = $url.'/'. $url_details;
                    }
                    //分析加/cn/
                    else if(in_array(self::$Folder_arr[$url],$urlplugin_2)){
                        $urllist[$urllist_i][$urllist_i_i] = $url.'/cn/'. $url_details;
                    }
                    //分析加/news/
                    else if(in_array(self::$Folder_arr[$url],$urlplugin_3)){
                        $urllist[$urllist_i][$urllist_i_i] = $url.'/news/'. $url_details;
                    }
                    //分析加/Site/Exbition/
                    else if(in_array(self::$Folder_arr[$url],$urlplugin_4)){
                        $urllist[$urllist_i][$urllist_i_i] = $url.'/Site/Exbition/'. $url_details;
                    }
                    //分析不加/
                    else{
                        $urllist[$urllist_i][$urllist_i_i] = $url. $url_details;
                    }

                    if($testnumber == 1){
                        echo ':::',$urllist[$urllist_i][$urllist_i_i],'<br />','<br />';
                    }

                    //统一处理
                    //删除amp符号
                    $urllist[$urllist_i][$urllist_i_i] = str_replace('amp','',$urllist[$urllist_i][$urllist_i_i]);

                    //$urllist[$urllist_i][$urllist_i_i] = str_replace('/','.',$urllist[$urllist_i][$urllist_i_i]);
                    //$urllist[$urllist_i][$urllist_i_i] = str_replace('\\','.',$urllist[$urllist_i][$urllist_i_i]);
                    ++$urllist_i_i;
                    $contents = mb_substr($contents,$pos+5);
                    $pos = mb_strpos($contents, $tags);
                }
            }
            ++$urllist_i;
            ++$temp_i;
        }
        //var_dump($urllist);die;
        //echo $path;die;

        if($testnumber == 1){
            echo '<br />','The Urllist!!!!';
            var_dump($urllist);
            echo '<br />';
        }

        $temp_i = 0;
        while (isset($urllist[$temp_i])){
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);
            ++$temp_i;
        }

        if($testnumber == 1){
            //echo $path.'/'.$filename[$temp_i];
            echo $url,'<br />';
            var_dump($urllist);
            echo '<br />';
        }

        /* echo $url,'<br>';
         var_dump($urllist);
         echo '<br>';*/

        $fun = $controllerall[$url];
        $this->$fun($urllist,$path,$url,$controllerall[$url]);
    }

    protected function fun0($url,$path,$filename){
        //判断日期文件夹
        if(!is_dir($path.'/'.date('Y_m_d'))){
            if(!is_dir($path.'/'.date('Y_m_d',strtotime("-1 day")))){
                if(!is_dir($path.'/'.date('Y_m_d',strtotime("+1 day")))){
                    return false;
                }else{
                    $path = $path.'/'.date('Y_m_d',strtotime("+1 day"));
                }
            }else{
                $path = $path.'/'.date('Y_m_d',strtotime("-1 day"));
            }
        }else{
            $path = $path.'/'.date('Y_m_d');
        }

        $temp_i = 0;
        $urllist = array();
        $urllist_i = 0;

        while(isset($filename[$temp_i])){
            if(!file_exists($path.'/'.$filename[$temp_i])){
                ++$temp_i;
                continue;
            }else{
                $tags = '/cn/exhibition/detail';
                $contents = file_get_contents($path.'/'.$filename[$temp_i]);
                $pos = 0;
                $urllist_i_i = 0;
                while($pos !== false) {
                    $pos = mb_strpos($contents, $tags);
                    $contents = mb_substr($contents,$pos);
                    $pos = mb_strpos($contents,'"');
                    $urllist[$urllist_i][$urllist_i_i] = $url.  mb_substr($contents,0,$pos);
                    ++$urllist_i_i;
                    $contents = mb_substr($contents,$pos);
                    $pos = mb_strpos($contents, $tags);
                }

            }
            ++$urllist_i;
            ++$temp_i;
        }
        //var_dump($urllist);die;

    }
    //on
    protected function Redbri($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //$url主页 $websitename本函数名
        //下载所有详情页
        //echo 'path:'.$path.'<br />';

        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //$path_temp = $path;
        //echo '$path_temp'.$path_temp;die;

        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;

        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //echo $filename[$temp_i][$temp_i_i];
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //要存储的信息数组
                $detailsInfo = array();
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset="'));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);

                $pos = mb_strpos($contents,'innerPage needScroll');
                $contents = mb_substr($contents,$pos);
                $pos = mb_strpos($contents,'h3>');
                /*echo $pos.'<br />';
                echo $contents;die;*/
                $contents = mb_substr($contents,$pos+mb_strlen('h3>'));
                $pos = mb_strpos($contents,'</h3');
                $detailsInfo['name'] = iconv('utf-8',$charset,mb_substr($contents,0,$pos));

                //echo $detailsInfo['name'];die;

                $pos = mb_strpos($contents,'time>');
                $contents = mb_substr($contents,$pos +mb_strlen('time>'));
                $pos = mb_strpos($contents,'</time');
                $temp_str = iconv('utf-8',$charset,mb_substr($contents,0,$pos));
                $temp_arr = explode(' ',$temp_str);
                $detailsInfo['opentimestart'] = preg_replace('/(\\D)+/','-',$temp_arr[0]);
                if(mb_strlen($detailsInfo['opentimestart']) > mb_strlen(preg_replace('/(\\D)+/','-',$temp_arr[2]))+1) {
                    $detailsInfo['opentimeend'] = explode('-', $detailsInfo['opentimestart'])[0] . '-' . preg_replace('/(\\D)+/', '-', $temp_arr[2]);
                }else{
                    $detailsInfo['opentimeend'] =  preg_replace('/(\\D)+/', '-', $temp_arr[2]);

                }
                /*$contents = mb_substr($contents,$pos);
                $pos = mb_strpos($contents,'</tr');
                $detailsInfo['organizers'] = iconv('utf-8','',strip_tags(mb_substr($contents,0,$pos)));
                $contents = mb_substr($contents,$pos);*/
                $pos = mb_strpos($contents,'￥');
                if($pos!==false) {
                    //$pos = mb_strpos($contents,iconv($charset,'','￥'));
                    //echo $pos;die;
                    $contents = mb_substr($contents, $pos + mb_strlen('￥'));
                    $pos = mb_strpos($contents, '</td');
                    $detailsInfo['fee'] = strip_tags(mb_substr($contents, 0, $pos));
                }else{
                    $pos = mb_strpos($contents,'票价');
                    $contents = mb_substr($contents, $pos + mb_strlen('票价'));
                    $pos = mb_strpos($contents, '</td');
                    $detailsInfo['fee'] = strip_tags(mb_substr($contents, 0, $pos));
                }
                //echo $detailsInfo['fee'] ;die;

                $contents = mb_substr($contents,$pos);
                $pos = mb_strpos($contents,'</article');
                $detailsInfo['introduction'] = strip_tags(iconv('utf-8',$charset,mb_substr($contents,0,$pos)));

                if(!is_dir(ROOT_PATH.'exhibits')) mkdir(ROOT_PATH.'exhibits');
                if(!is_dir(self::$mFilePath)) {
                    mkdir(self::$mFilePath);
                    chmod(self::$mFilePath,0777);
                }
                $path_temp = self::$mFilePath.date('Ymd');
                if(!is_dir($path_temp)){
                    mkdir($path_temp);
                    chmod($path_temp,0777);
                }

                $findbyname=model('maexhibitions')->find("name='".$detailsInfo['name']."'");
                if(!$findbyname) {
                    $detailsInfo['visittime'] = time();
                    $exid = model('maexhibitions')->insert($detailsInfo);

                    //$imgurl

                    $temp_imgurl_i = 0;
                    while(isset($imgurl[$temp_imgurl_i])) {

                        /*echo '$temp_i::',$temp_imgurl_i,'<br />';
                        echo $imgUrlList[$temp_imgurl_i]['imgurl'];
                        echo '<br />';*/

                        $imgpath = $this->saveImage($imgurl[$temp_imgurl_i]['imgurl']);
                        if ($imgpath === false) {
                            ++$temp_imgurl_i;
                            continue;
                        }
                        if($imgpath != '') {
                            $imgurl[$temp_imgurl_i]['imgpath'] = 'exhibits/' . date('Ymd') . '/' . $imgpath;
                        }
                        $imgurl[$temp_imgurl_i]['exhibitionsID'] = $exid;
                        model('maexhibits')->insert($imgurl[$temp_imgurl_i]);
                        ++$temp_imgurl_i;

                    }
                }
                ++$temp_i_i;
            }
            //die;
            ++$temp_i;
        }
    }
    //on   ps:no time
    protected function Mcafac($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        //echo 'Mcafac:','<br />';
        //var_dump($urllist);
        //die;

        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {

                //echo '<br />','抓取页面：',$urllist[$temp_i][$temp_i_i],'<br />';
                $urllist[$temp_i][$temp_i_i] = str_replace(' ','%20',$urllist[$temp_i][$temp_i_i]);

                //echo '<br />','抓取页面：',$urllist[$temp_i][$temp_i_i],'<br />';

                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);

                $pos = mb_strpos($contents,'li style=""><a class="current"');
                if($pos === false){
                    ++$temp_i_i;
                    continue;
                }

                $pos = mb_strpos($contents,'textTitle fc bc_hover">');
                $contents = mb_substr($contents,$pos+mb_strlen('textTitle fc bc_hover">'));
                $pos = mb_strpos($contents,'</div');
                $detailsInfo['name'] = strip_tags(iconv('utf-8',$charset,mb_substr($contents,0,$pos)));

                $pos = mb_strpos($contents,'http://photo.cafa.com.cn');
                $contents = mb_substr($contents,$pos);
                $pos = mb_strpos($contents,'"');
                $detailsInfo['pagehomeimgurl'] = iconv('utf-8',$charset,mb_substr($contents,0,$pos));

                $contents = mb_substr($contents,$pos+mb_strlen('" />'));
                $pos = mb_strpos($contents,'<div class="clear"');
                $detailsInfo['introduction'] = iconv('utf-8',$charset,strip_tags(mb_substr($contents,0,$pos)));

                if(!is_dir(ROOT_PATH.'exhibits')) mkdir(ROOT_PATH.'exhibits');
                if(!is_dir(self::$mFilePath)) {
                    mkdir(self::$mFilePath);
                    chmod(self::$mFilePath,0777);
                }
                $path_temp = self::$mFilePath.date('Ymd');
                if(!is_dir($path_temp)){
                    mkdir($path_temp);
                    chmod($path_temp,0777);
                }

                $findbyname=model('maexhibitions')->find("name='".$detailsInfo['name']."'");
                if(!$findbyname) {
                    $detailsInfo['visittime'] = time();
                    $exid = model('maexhibitions')->insert($detailsInfo);

                    //$imgurl

                    $temp_imgurl_i = 0;
                    while(isset($imgurl[$temp_imgurl_i])) {

                        /*echo '$temp_i::',$temp_imgurl_i,'<br />';
                        echo $imgUrlList[$temp_imgurl_i]['imgurl'];
                        echo '<br />';*/

                        $imgpath = $this->saveImage($imgurl[$temp_imgurl_i]['imgurl']);
                        if ($imgpath === false) {
                            ++$temp_imgurl_i;
                            continue;
                        }
                        if($imgpath != '') {
                            $imgurl[$temp_imgurl_i]['imgpath'] = 'exhibits/' . date('Ymd') . '/' . $imgpath;
                        }else{
                            ++$temp_imgurl_i;
                            continue;
                        }
                        $imgurl[$temp_imgurl_i]['exhibitionsID'] = $exid;
                        model('maexhibits')->insert($imgurl[$temp_imgurl_i]);
                        ++$temp_imgurl_i;

                    }
                }
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        // die;
    }
    //on
    protected function Tjarto($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //echo '进入Tjarto','<br />';
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;

        //echo 'Tjarto!!!!';
        //var_dump($filename);
        //echo '<br />';

        while(isset($filename[$temp_i])){
            //echo '进入Tjarto的while1'.'<br />';
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容

                //echo $path_details;die;
                //echo 'path_details!!!:'.$path_details.'<br />';
                $contents = $this->getDetailsContents($path_details);
                //echo $contents;die;
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset=');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);

                $pos = mb_strpos($contents,'http://imgs.orgcc.com/Thumb/');
                $contents = mb_substr($contents,$pos);
                $pos = mb_strpos($contents,'"');
                $detailsInfo['pagehomeimgurl'] = mb_substr($contents,0,$pos);
                //echo $detailsInfo['pagehomeimgurl'];die;

                $pos = mb_strpos($contents,'<h4>');
                $contents = mb_substr($contents,$pos+mb_strlen('<h4>'));
                $pos = mb_strpos($contents,'</h4');
                if(mb_substr($contents,0,$pos) != strip_tags(mb_substr($contents,0,$pos))){
                    ++$temp_i_i;
                    continue;
                }
                $detailsInfo['name'] = strip_tags(mb_substr($contents,0,$pos));
                if($detailsInfo['name'] == '') {
                    ++$temp_i_i;
                    continue;
                }
                //echo $contents;
                $pos = mb_strpos($contents,'p>');
                $contents = mb_substr($contents,$pos + mb_strlen('p>'));
                $pos = mb_strpos($contents,'<br');
                //echo '其实是这样的'.mb_substr($contents,0,$pos).'<br />';
                $temp_time = iconv('utf-8',$charset,mb_substr($contents,0,$pos));
                $temp_time = explode(' ',$temp_time);
                $detailsInfo['opentimestart'] = mb_substr($temp_time[0],mb_strpos($temp_time[0],'2'));
                $detailsInfo['opentimeend'] = $temp_time[2];
                //$contents = mb_substr($contents,$pos+mb_strlen('<br />'));
                //echo 'charset!!!!'.$charset.'<br />';
                //echo $detailsInfo['opentimestart'].'<br />';
                //echo $detailsInfo['opentimeend'].'<br>';


                $pos = mb_strpos($contents,'/>');
                $contents = mb_substr($contents,$pos+mb_strlen('/>'));
                $pos = mb_strpos($contents,'<br');
                $temp_city = iconv('utf-8',$charset,mb_substr($contents,0,$pos));
                $pos_temp = mb_strpos($temp_city,'：');
                $detailsInfo['city'] = explode(' ',mb_substr($temp_city,$pos_temp))[0];

                //echo htmlentities($contents);die;

                $pos = mb_strpos($contents,'/>');
                $contents = mb_substr($contents,$pos+mb_strlen('/>'));
                $pos = mb_strpos($contents,'</');
                $detailsInfo['address'] = iconv('utf-8',$charset,mb_substr($contents,0,$pos));

                $pos = mb_strpos($contents,'id="qianyan">');
                $contents = mb_substr($contents,$pos+mb_strlen('id="qianyan">'));
                $pos = mb_strpos($contents,'<div id="dismore');
                $detailsInfo['introduction'] = strip_tags(iconv('utf-8',$charset,mb_substr($contents,0,$pos)));

                //echo $contengts.'<br />';
                //echo $detailsInfo['introduction'];die;

                //imgurl  ->  $imgurl
                $pos = mb_strpos($contents,'http://imgs.orgcc.com/Thumb');
                $imgurl = array();
                $temp_imgurl_i = 0;
                while($pos !== false) {
                    $contents = mb_substr($contents, $pos);
                    $pos = mb_strpos($contents, '"');
                    //$imgurl[$temp_imgurl_i]['']
                    $imgurl[$temp_imgurl_i]['imgurl'] = iconv('utf-8',$charset,mb_substr($contents,0,$pos));
                    $pos = mb_strpos($contents,'alt="');
                    $contents = mb_substr($contents,$pos+mb_strlen('alt="'));
                    $pos = mb_strpos($contents,'"');
                    $imgurl[$temp_imgurl_i]['name'] = iconv('utf-8',$charset,mb_substr($contents,0,$pos));

                    $contents = mb_substr($contents,$pos);
                    $pos = mb_strpos($contents,'http://imgs.orgcc.com/Thumb');
                    ++$temp_imgurl_i;
                }

                if(!is_dir(ROOT_PATH.'exhibits')) mkdir(ROOT_PATH.'exhibits');
                if(!is_dir(self::$mFilePath)) {
                    mkdir(self::$mFilePath);
                    chmod(self::$mFilePath,0777);
                }
                $path_temp = self::$mFilePath.date('Ymd');
                if(!is_dir($path_temp)){
                    mkdir($path_temp);
                    chmod($path_temp,0777);
                }

                $findbyname=model('maexhibitions')->find("name='".$detailsInfo['name']."'");
                if(!$findbyname) {
                    $detailsInfo['visittime'] = time();
                    $exid = model('maexhibitions')->insert($detailsInfo);

                    //$imgurl

                    $temp_imgurl_i = 0;
                    while(isset($imgurl[$temp_imgurl_i])) {

                        /*echo '$temp_i::',$temp_imgurl_i,'<br />';
                        echo $imgUrlList[$temp_imgurl_i]['imgurl'];
                        echo '<br />';*/

                        $imgpath = $this->saveImage($imgurl[$temp_imgurl_i]['imgurl']);
                        if ($imgpath === false) {
                            ++$temp_imgurl_i;
                            continue;
                        }
                        if($imgpath != '') {
                            $imgurl[$temp_imgurl_i]['imgpath'] = 'exhibits/' . date('Ymd') . '/' . $imgpath;
                        }else{
                            ++$temp_imgurl_i;
                            continue;
                        }
                        $imgurl[$temp_imgurl_i]['exhibitionsID'] = $exid;
                        model('maexhibits')->insert($imgurl[$temp_imgurl_i]);
                        ++$temp_imgurl_i;

                    }
                }
                ++$temp_i_i;
            }
            //die;
            ++$temp_i;
        }
    }
    //on
    protected function Timesa($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //$url 主页 $websitename 存储如website的名字
        //下载所有详情页
        //$path_temp 存储图片的地址
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];

        //echo 'path!!'.$path.'<br />';

        /*      echo 'urllist!!!:','<br />';
              var_dump($urllist);
              echo '<br />','$url!!:',$url,'<br />','websitename!!:',$websitename,'<br />','path_temp!!!:',$path_temp,'<br />';die;*/

        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        $model = D('Maexhibitions');
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            $detailsInfo = array();
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);

                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset="'));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);

                $pos = mb_strpos($contents,'h1>');
                $contents = mb_substr($contents,$pos+mb_strlen('h1>'));
                $pos = mb_strpos($contents,'</h1');
                $detailsInfo['name'] = iconv('utf-8',$charset,mb_substr($contents,0,$pos));

                //echo 'filename!!:',$path_details,'<br />';
                //echo 'name!!:',$detailsInfo['name'],'<br />';

                $pos = mb_strpos($contents,'img src="');
                $contents = mb_substr($contents,$pos + mb_strlen('img src="'));
                $pos = mb_strpos($contents,'"');
                $detailsInfo['pagehomeimgurl'] = $url.'/'.mb_substr($contents,0,$pos);

                $pos = mb_strpos($contents,'mobanleft">');
                $contents = mb_substr($contents,$pos + mb_strlen('mobanleft">'));
                $pos = mb_strpos($contents,'<div class="mobanright');
                $temp_mix = preg_replace("/(\s|\&nbsp\;|　|\xc2\xa0)/", "", iconv('utf-8',$charset,mb_substr($contents,0,$pos)));
                //iconv('utf-8',$charset,mb_substr($contents,0,$pos));
                //主要获取 主办  承办（协办） 展览时间   展览地址  策展人
                $posstart = mb_strpos($temp_mix,'主办');
                if($posstart !==false){
                    $temp_mix_useless = mb_substr($temp_mix,$posstart+mb_strlen('主办'));
                    $posend = mb_strpos($temp_mix_useless,'</span');
                    $detailsInfo['organizers'] = strip_tags(mb_substr($temp_mix_useless,0,$posend));
                    if(mb_strlen($detailsInfo['organizers']) <= 4){
                        $temp_mix_useless = mb_substr($temp_mix_useless,$posend+mb_strlen('</span')+1);
                        $posend = mb_strpos($temp_mix_useless,'</span');
                        $detailsInfo['organizers'] = strip_tags(mb_substr($temp_mix_useless,0,$posend));
                    }
                }

                $posstart = mb_strpos($temp_mix,'承办');
                if($posstart !==false){
                    $temp_mix_useless = mb_substr($temp_mix,$posstart+mb_strlen('承办'));
                    $posend = mb_strpos($temp_mix_useless,'</span');
                    $detailsInfo['co-organizers'] = strip_tags(mb_substr($temp_mix_useless,0,$posend));
                    if(mb_strlen($detailsInfo['co-organizers']) <= 4){
                        $temp_mix_useless = mb_substr($temp_mix_useless,$posend+mb_strlen('</span')+1);
                        $posend = mb_strpos($temp_mix_useless,'</span');
                        $detailsInfo['co-organizers'] = strip_tags(mb_substr($temp_mix_useless,0,$posend));
                    }
                }

                $posstart = mb_strpos($temp_mix,'展览地点');
                if($posstart !==false){
                    $temp_mix_useless = mb_substr($temp_mix,$posstart+mb_strlen('展览地点'));
                    $posend = mb_strpos($temp_mix_useless,'</span');
                    $detailsInfo['address'] = strip_tags(mb_substr($temp_mix_useless,0,$posend));
                    if(mb_strlen($detailsInfo['address']) <= 4){
                        $temp_mix_useless = mb_substr($temp_mix_useless,$posend+mb_strlen('</span')+1);
                        $posend = mb_strpos($temp_mix_useless,'</span');
                        $detailsInfo['address'] = strip_tags(mb_substr($temp_mix_useless,0,$posend));
                    }
                }

                $posstart = mb_strpos($temp_mix,'展览时间');
                if($posstart !==false){
                    $temp_mix_useless = mb_substr($temp_mix,$posstart+mb_strlen('展览时间'));
                    $posend = mb_strpos($temp_mix_useless,'</span');
                    $temp_time = strip_tags(mb_substr($temp_mix_useless,0,$posend));
                    //echo 'temp_time~~',$temp_time,'<br />';
                    if(mb_strlen($temp_time) <= 4){
                        $temp_mix_useless = mb_substr($temp_mix_useless,$posend+mb_strlen('</span')+1);
                        $posend = mb_strpos($temp_mix_useless,'</span');
                        $temp_time = strip_tags(mb_substr($temp_mix_useless,0,$posend));
                    }
                    $temp_tags = '';
                    $posstart = mb_strpos($temp_time,'：');
                    if($posstart !== false){
                        $temp_tags = '：';
                    }
                    $posstart = mb_strpos($temp_time,':');
                    if($posstart !== false){
                        $temp_tags = ':';
                    }
                    if($temp_tags !== ''){
                        $temp_time = str_replace($temp_tags,'',$temp_time);
                    }
                    $temp_timestart = explode('-',$temp_time)[0];
                    $temp_timeend = explode('-',$temp_time)[1];
                    $temp_timestart = preg_replace('/(\\D)+/','-',$temp_timestart);
                    $temp_timeend = explode('-',$temp_timestart)[0].'-'.preg_replace('/(\\D)+/','-',$temp_timeend);

                    $detailsInfo['opentimestart'] = $temp_timestart;
                    $detailsInfo['opentimeend'] = $temp_timeend;
                }

                $contents = mb_substr($contents,$pos);
                $pos = mb_strpos($contents,'</div');
                $detailsInfo['introduction'] = strip_tags(iconv('utf-8',$charset,mb_substr($contents,0,$pos)));

                $pos = mb_strpos($contents,'slides show-slides-list');
                $contents = mb_substr($contents,$pos);
                $pos = mb_strpos($contents,'show-place');
                $contents = mb_substr($contents,0,$pos);

                $imgurl = array();
                $temp_imgurl_i = 0;
                $pos = mb_strpos($contents,'<a href="');
                while($pos !== false){
                    $contents = mb_substr($contents,$pos +mb_strlen('<a href="'));
                    $pos = mb_strpos($contents,'<a href="');
                    $temp_content_imgurl = mb_substr($contents,0,$pos);
                    $temp_pos = mb_strpos($temp_content_imgurl,'"');
                    $imgurl[$temp_imgurl_i]['imgurl']= $url.'/'.mb_substr($temp_content_imgurl,0,$temp_pos);
                    $temp_pos = mb_strpos($temp_content_imgurl,'h3>');
                    $temp_content_imgurl = mb_substr($temp_content_imgurl,$temp_pos+mb_strlen('h3>'));
                    $temp_pos = mb_strpos($temp_content_imgurl,'</h3');
                    $imgurl[$temp_imgurl_i]['name'] = strip_tags(iconv('utf-8',$charset,mb_substr($temp_content_imgurl,0,$temp_pos)));
                    $temp_pos = mb_strpos($temp_content_imgurl,'intro">');
                    $temp_content_imgurl = mb_substr($temp_content_imgurl,$temp_pos+mb_strlen('intro">'));
                    $temp_pos = mb_strpos($temp_content_imgurl,'<br');
                    $imgurl[$temp_imgurl_i]['author'] = mb_substr($temp_content_imgurl,0,$temp_pos);
                    $temp_content_imgurl = mb_substr($temp_content_imgurl,$temp_pos+mb_strlen('<br')+1);
                    $temp_pos = mb_strpos($temp_content_imgurl,'<br');
                    $imgurl[$temp_imgurl_i]['years'] = mb_substr($temp_content_imgurl,0,$temp_pos);
                    $temp_content_imgurl = mb_substr($temp_content_imgurl,$temp_pos+mb_strlen('<br')+1);
                    $temp_pos = mb_strpos($temp_content_imgurl,'<br');
                    $imgurl[$temp_imgurl_i]['type'] = mb_substr($temp_content_imgurl,0,$temp_pos);
                    $temp_content_imgurl = mb_substr($temp_content_imgurl,$temp_pos+mb_strlen('<br')+1);
                    $temp_pos = mb_strpos($temp_content_imgurl,'</div');
                    $imgurl[$temp_imgurl_i]['size'] = mb_substr($temp_content_imgurl,0,$temp_pos);

                    $contents = mb_substr($contents,$pos +mb_strlen('<a href="'));
                    $pos = mb_strpos($contents,'<a href="');
                    ++$temp_imgurl_i;
                }

                if(!is_dir(ROOT_PATH.'exhibits')) mkdir(ROOT_PATH.'exhibits');
                if(!is_dir(self::$mFilePath)) {
                    mkdir(self::$mFilePath);
                    chmod(self::$mFilePath,0777);
                }
                $path_temp = self::$mFilePath.date('Ymd');
                if(!is_dir($path_temp)){
                    mkdir($path_temp);
                    chmod($path_temp,0777);
                }

                $findbyname=model('maexhibitions')->find("name='".$detailsInfo['name']."'");
                if(!$findbyname) {
                    $detailsInfo['visittime'] = time();
                    $exid = model('maexhibitions')->insert($detailsInfo);

                    //$imgurl

                    $temp_imgurl_i = 0;
                    while(isset($imgurl[$temp_imgurl_i])) {

                        /*echo '$temp_i::',$temp_imgurl_i,'<br />';
                        echo $imgUrlList[$temp_imgurl_i]['imgurl'];
                        echo '<br />';*/

                        $imgpath = $this->saveImage($imgurl[$temp_imgurl_i]['imgurl']);
                        if ($imgpath === false) {
                            ++$temp_imgurl_i;
                            continue;
                        }
                        if($imgpath != '') {
                            $imgurl[$temp_imgurl_i]['imgpath'] = 'exhibits/' . date('Ymd') . '/' . $imgpath;
                        }else{
                            ++$temp_imgurl_i;
                            continue;
                        }
                        $imgurl[$temp_imgurl_i]['exhibitionsID'] = $exid;
                        model('maexhibits')->insert($imgurl[$temp_imgurl_i]);
                        ++$temp_imgurl_i;

                    }
                }
                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //on  ps:have no time and it's stupid
    protected function Ssmuse($urllist,$path,$url,$websitename){
        return 0;
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        $model = D('Maexhibitions');
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);

                $pos = mb_strpos($contents,'h2>');
                $contents = mb_substr($contents,$pos+mb_strlen('h2>'));
                $pos = mb_strpos($contents,'</h2');
                $detailsInfo['name'] = mb_substr($contents,0,$pos);

                $pos = mb_strpos($contents,'class="texta2">');
                $contents = mb_substr($contents,$pos + mb_strlen('class="texta2">'));



                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //on
    protected function Zfjmsg($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        $model = D('Maexhibitions');
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            $detailsInfo = array();
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);

                $pos = mb_strpos($contents,'h1>');
                $contents = mb_substr($contents,$pos+mb_strlen('h1>'));
                $pos = mb_strpos($contents,'</h1');
                $detailsInfo['name'] = strip_tags(iconv('utf-8',$charset,mb_substr($contents,0,$pos)));

                $pos = mb_strpos($contents,'img src="');
                $contents = mb_substr($contents,$pos+mb_strlen('img src="'));
                $pos = mb_strpos($contents,'"');
                $detailsInfo['pagehomeimgurl'] = mb_substr($contents,0,$pos);

                $pos = mb_strpos($contents,'class="span_color">');
                $contents = mb_substr($contents,$pos +mb_strlen('class="span_color">'));
                $pos = mb_strpos($contents,'class="article_content">');
                //这段取 展览时间 展览地点 策展人 主办单位 承办
                $temp_content = iconv('utf-8',$charset,mb_substr($contents,0,$pos));
                if($temp_content != ''){
                    $posstart = mb_strpos($temp_content,'展览时间');
                    if($posstart !==false){
                        $temp_content_once = mb_substr($temp_content,$posstart);
                        $posstart = mb_strpos($temp_content_once,'：');
                        $posend = mb_strpos($temp_content_once,'</p');
                        $temp_time = mb_substr($temp_content_once,$posstart+mb_strlen('：'),$posend);
                        $detailsInfo['opentimestart'] = explode(' ～',$temp_time)[0];
                        $detailsInfo['opentimeend'] = explode(' ～',$temp_time)[1];
                    }
                    $posstart = mb_strpos($temp_content,'展览地点');
                    if($posstart !==false) {
                        $temp_content_once = mb_substr($temp_content, $posstart);
                        $posstart = mb_strpos($temp_content_once, '：');
                        $posend = mb_strpos($temp_content_once, '</p');
                        $detailsInfo['address'] = strip_tags(mb_substr($temp_content_once, $posstart + mb_strlen('：'), $posend));
                    }
                    $posstart = mb_strpos($temp_content,'策 展 人');
                    if($posstart !==false) {
                        $temp_content_once = mb_substr($temp_content, $posstart);
                        $posstart = mb_strpos($temp_content_once, '：');
                        $posend = mb_strpos($temp_content_once, '</p');
                        $detailsInfo['curator'] = strip_tags(mb_substr($temp_content_once, $posstart + mb_strlen('：'), $posend));
                    }
                    $posstart = mb_strpos($temp_content,'主办单位');
                    if($posstart !==false) {
                        $temp_content_once = mb_substr($temp_content, $posstart);
                        $posstart = mb_strpos($temp_content_once, '：');
                        $posend = mb_strpos($temp_content_once, '</p');
                        $detailsInfo['organizers'] = strip_tags(mb_substr($temp_content_once, $posstart + mb_strlen('：'), $posend));
                    }
                    $posstart = mb_strpos($temp_content,'承办单位');
                    if($posstart !==false) {
                        $temp_content_once = mb_substr($temp_content, $posstart);
                        $posstart = mb_strpos($temp_content_once, '：');
                        $posend = mb_strpos($temp_content_once, '</p');
                        $detailsInfo['co-organizers'] = strip_tags(mb_substr($temp_content_once, $posstart + mb_strlen('：'), $posend));
                    }
                }

                $contents = mb_substr($contents,$pos+mb_strlen('class="article_content">'));
                $pos = mb_strpos($contents,'<div class="sub_section_tab"');
                $detailsInfo['introduction'] = strip_tags(iconv('utf-8',$charset,mb_substr($contents,0,$pos)));

                //Think\Log::write('日志写入成功','WARN');

                if(!is_dir(ROOT_PATH.'exhibits')) mkdir(ROOT_PATH.'exhibits');
                if(!is_dir(self::$mFilePath)) {
                    mkdir(self::$mFilePath);
                    chmod(self::$mFilePath,0777);
                }
                $path_temp = self::$mFilePath.date('Ymd');
                if(!is_dir($path_temp)){
                    mkdir($path_temp);
                    chmod($path_temp,0777);
                }

                $findbyname=model('maexhibitions')->find("name='".$detailsInfo['name']."'");
                if(!$findbyname) {
                    $detailsInfo['visittime'] = time();
                    $exid = model('maexhibitions')->insert($detailsInfo);

                    //$imgurl

                    $temp_imgurl_i = 0;
                    while(isset($imgurl[$temp_imgurl_i])) {

                        /*echo '$temp_i::',$temp_imgurl_i,'<br />';
                        echo $imgUrlList[$temp_imgurl_i]['imgurl'];
                        echo '<br />';*/

                        $imgpath = $this->saveImage($imgurl[$temp_imgurl_i]['imgurl']);
                        if ($imgpath === false) {
                            ++$temp_imgurl_i;
                            continue;
                        }
                        if($imgpath != '') {
                            $imgurl[$temp_imgurl_i]['imgpath'] = 'exhibits/' . date('Ymd') . '/' . $imgpath;
                        }else{
                            ++$temp_imgurl_i;
                            continue;
                        }
                        $imgurl[$temp_imgurl_i]['exhibitionsID'] = $exid;
                        model('maexhibits')->insert($imgurl[$temp_imgurl_i]);
                        ++$temp_imgurl_i;

                    }
                }
                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //on
    protected function Ccqago($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //echo 'Ccqago!!!!!'.'<br />';
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        $model = D('Maexhibitions');
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset="'));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);

                //echo 'charset!!!:'.$charset.'<br />';
                //echo htmlentities($contents);die;
                //echo $filename[$temp_i][$temp_i_i].'<br />';

                $pos = mb_strpos($contents,'h2>');
                $contents = mb_substr($contents,$pos+mb_strlen('h2>'));
                $pos = mb_strpos($contents,'</h2');
                $detailsInfo['name'] = iconv('utf-8',$charset,mb_substr($contents,0,$pos));
                $contents = mb_substr($contents,$pos+mb_strlen('</h2')+1);
                if($detailsInfo['name'] == '') {
                    ++$temp_i_i;
                    continue;
                }

                $pos = mb_strpos($contents,'<span class="more"');
                $temp_introduction = iconv('utf-8',$charset,mb_substr($contents,0,$pos));

                $ttttt_introduction = $temp_introduction;

                //echo htmlentities($ttttt_introduction);die;
                $posstart = mb_strpos($ttttt_introduction,'主办单位：');
                //echo $posstart;die;

                if($posstart !==false) {
                    $posend = mb_strpos($ttttt_introduction, '</span');
                    while ($posend < $posstart) {
                        $ttttt_introduction = mb_substr($ttttt_introduction, $posend + mb_strlen('</span'));
                        $posstart = mb_strpos($ttttt_introduction, '主办单位：');
                        $posend = mb_strpos($ttttt_introduction, '</span');
                    }
                    $detailsInfo['organizers'] = strip_tags(mb_substr($ttttt_introduction, $posstart, $posend));
                }

                $ttttt_introduction = $temp_introduction;
                $posstart = mb_strpos($ttttt_introduction,'展览地点：');
                if($posstart !==false) {
                    $posend = mb_strpos($ttttt_introduction, '</span');
                    while ($posend < $posstart) {
                        $ttttt_introduction = mb_substr($ttttt_introduction, $posend + mb_strlen('</span'));
                        $posstart = mb_strpos($ttttt_introduction, '展览地点：');
                        $posend = mb_strpos($ttttt_introduction, '</span');
                    }
                    $detailsInfo['address'] = strip_tags(mb_substr($ttttt_introduction, $posstart, $posend));
                }

                $ttttt_introduction = $temp_introduction;
                $posstart = mb_strpos($ttttt_introduction,'展览时间：');
                if($posstart !==false) {
                    $posend = mb_strpos($ttttt_introduction, '</span');
                    while ($posend < $posstart) {
                        $ttttt_introduction = mb_substr($ttttt_introduction, $posend + mb_strlen('</span'));
                        $posstart = mb_strpos($ttttt_introduction, '展览时间：');
                        $posend = mb_strpos($ttttt_introduction, '</span');
                    }
                    $temp_time = mb_substr($ttttt_introduction, $posstart, $posend);
                    $temp_arr = explode('—',$temp_time);
                    $detailsInfo['opentimestart'] = preg_replace('/(\\D)+/','-',$temp_arr[0]);
                    $detailsInfo['opentimeend'] = explode('-',$detailsInfo['opentimestart'])[0].'-'.preg_replace('/(\\D)+/','-',$temp_arr[1]);
                }

                $imgurl = array();
                $imgurl_i = 0;
                $ttttt_introduction = $temp_introduction;
                $pos = mb_strpos($ttttt_introduction,'http://www.ccqag.org/upload');
                while ($pos !==false) {
                    $ttttt_introduction = mb_substr($ttttt_introduction, $pos);
                    $pos = mb_strpos($ttttt_introduction, '"');
                    $imgurl[$imgurl_i]['imgurl'] = mb_substr($ttttt_introduction,0,$pos);
                    $pos = mb_strpos($ttttt_introduction,'alt="');
                    $ttttt_introduction = mb_substr($ttttt_introduction,$pos+mb_strlen('alt="'));
                    $pos = mb_strpos($ttttt_introduction,'"');
                    $imgurl[$imgurl_i]['name'] = mb_substr($ttttt_introduction,0,$pos);

                    $pos = mb_strpos($ttttt_introduction,'http://www.ccqag.org/upload');
                    ++$imgurl_i;
                }
                $detailsInfo['introduction'] = strip_tags($temp_introduction);

                //$model_temp => kill  $model => model('maexhibitions')
                //
                //
                //

                if(!is_dir(ROOT_PATH.'exhibits')) mkdir(ROOT_PATH.'exhibits');
                if(!is_dir(self::$mFilePath)) {
                    mkdir(self::$mFilePath);
                    chmod(self::$mFilePath,0777);
                }
                $path_temp = self::$mFilePath.date('Ymd');
                if(!is_dir($path_temp)){
                    mkdir($path_temp);
                    chmod($path_temp,0777);
                }

                $findbyname=model('maexhibitions')->find("name='".$detailsInfo['name']."'");
                if(!$findbyname) {
                    $detailsInfo['visittime'] = time();
                    $exid = model('maexhibitions')->insert($detailsInfo);

                    //$imgurl

                    $temp_imgurl_i = 0;
                    while(isset($imgurl[$temp_imgurl_i])) {

                        /*echo '$temp_i::',$temp_imgurl_i,'<br />';
                        echo $imgUrlList[$temp_imgurl_i]['imgurl'];
                        echo '<br />';*/

                        $imgpath = $this->saveImage($imgurl[$temp_imgurl_i]['imgurl']);
                        if ($imgpath === false) {
                            ++$temp_imgurl_i;
                            continue;
                        }
                        if($imgpath != '') {
                            $imgurl[$temp_imgurl_i]['imgpath'] = 'exhibits/' . date('Ymd') . '/' . $imgpath;
                        }else{
                            ++$temp_imgurl_i;
                            continue;
                        }
                        $imgurl[$temp_imgurl_i]['exhibitionsID'] = $exid;
                        model('maexhibits')->insert($imgurl[$temp_imgurl_i]);
                        ++$temp_imgurl_i;

                    }
                }

                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //die;
    }
    //on  ps:The website is dead,haven't connect sql;
    protected function Hopear($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //on
    protected function Gdmoao($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            $detailsInfo = array();
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);

                if(mb_strlen($charset)>=10 || mb_strlen($charset)<1){
                    ++$temp_i_i;
                    continue;
                }

                $pos = mb_strpos($contents,'<title');
                if($pos === false){
                    ++$temp_i_i;
                    continue;
                }

                //$charset = 'utf-8';
                //echo '<br />',$path_details,'<br />';
                //echo 'charset=',$charset,'<br />';

                $pos = mb_strpos($contents,'h1>');
                if($pos === false){
                    ++$temp_i_i;
                    continue;
                }
                $contents = mb_substr($contents,$pos+mb_strlen('h1>'));
                $pos = mb_strpos($contents,'</h1');
                $detailsInfo['name'] = strip_tags(iconv($charset,'utf-8//TRANSLIT',mb_substr($contents,0,$pos)));
                $detailsInfo['name'] = str_replace('$mdash;','',$detailsInfo['name']);
                //echo 'name',$detailsInfo['name'],'<br />';

                $contents = mb_substr($contents,$pos+mb_strlen('</h1')+1);
                $pos = mb_strpos($contents,'h2>');
                $contents = mb_substr($contents,$pos+mb_strlen('h2>'));
                $pos = mb_strpos($contents,'</h2');
                $temp_format = iconv($charset,'utf-8//TRANSLIT',mb_substr($contents,0,$pos));

                $posstart = mb_strpos($temp_format,'展期：');
                if($posstart !== false){
                    $temp_format_once = mb_substr($temp_format,$posstart+mb_strlen('展期：'));
                    $posstart = mb_strpos($temp_format_once,'<br');
                    $temp_time = strip_tags(mb_substr($temp_format_once,0,$posstart));
                    $temp_time = str_replace('&mdash;',' ',$temp_time);

                    $temp_time = explode(' ',$temp_time);
                    $detailsInfo['opentimestart'] = preg_replace('/(\\D)+/','-',$temp_time[0]);
                    $temp_time_i = 1;
                    while($temp_time[$temp_time_i] == ''){
                        ++$temp_time_i;
                    }
                    $temp_endtime = preg_replace('/(\\D)+/','-',$temp_time[$temp_time_i]);

                    if(mb_strlen($temp_endtime)<=3){
                        $detailsInfo['opentimeend'] = explode('-',$detailsInfo['opentimestart'])[0].'-'.explode('-',$detailsInfo['opentimestart'])[1].'-'.$temp_endtime;
                    }elseif (mb_strlen($temp_endtime)>3 && mb_strlen($temp_endtime)<=6){
                        $detailsInfo['opentimeend'] = explode('-',$detailsInfo['opentimestart'])[0].'-'.$temp_endtime;
                    }
                }

                $posstart = mb_strpos($temp_format,'展厅：');
                if($posstart !== false){
                    $temp_format_once = mb_substr($temp_format,$posstart+mb_strlen('展厅：'));
                    $posstart = mb_strpos($temp_format_once,'<br');
                    $detailsInfo['address'] = strip_tags(mb_substr($temp_format_once,0,$posstart));
                }
                $contents = mb_substr($contents,$pos+mb_strlen('</h2')+1);
                $pos = mb_strpos($contents,'h3>');
                if($pos !== false){
                    $posend = mb_strpos($contents,'</h3');
                    $temp_once = iconv('utf-8',$charset,mb_substr($contents,$pos+mb_strlen('h3>',$posend)));
                    $posstart = mb_strpos($temp_once,'策 展 人：');
                    if($posstart !== false){
                        $temp_once = mb_substr($temp_once,$posstart);
                        $posstart = mb_strpos($temp_once,'<br');
                        $detailsInfo['curator'] = mb_substr($temp_once,0,$posstart);
                    }
                }
                $contents = mb_substr($contents,$pos+mb_strlen('h3>'));
                $pos = mb_strpos($contents,'<div class="clearfix');
                $detailsInfo['introduction'] = strip_tags(iconv($charset,'utf-8//TRANSLIT',mb_substr($contents,0,$pos+mb_strlen('h2>'))));

                //echo '介绍:',$detailsInfo['introduction'],'<br />';

                if(!is_dir(ROOT_PATH.'exhibits')) mkdir(ROOT_PATH.'exhibits');
                if(!is_dir(self::$mFilePath)) {
                    mkdir(self::$mFilePath);
                    chmod(self::$mFilePath,0777);
                }
                $path_temp = self::$mFilePath.date('Ymd');
                if(!is_dir($path_temp)){
                    mkdir($path_temp);
                    chmod($path_temp,0777);
                }

                $findbyname=model('maexhibitions')->find("name='".$detailsInfo['name']."'");
                if(!$findbyname) {
                    $detailsInfo['visittime'] = time();
                    $exid = model('maexhibitions')->insert($detailsInfo);

                    //$imgurl

                    $temp_imgurl_i = 0;
                    while(isset($imgurl[$temp_imgurl_i])) {

                        /*echo '$temp_i::',$temp_imgurl_i,'<br />';
                        echo $imgUrlList[$temp_imgurl_i]['imgurl'];
                        echo '<br />';*/

                        $imgpath = $this->saveImage($imgurl[$temp_imgurl_i]['imgurl']);
                        if ($imgpath === false) {
                            ++$temp_imgurl_i;
                            continue;
                        }
                        if($imgpath != '') {
                            $imgurl[$temp_imgurl_i]['imgpath'] = 'exhibits/' . date('Ymd') . '/' . $imgpath;
                        }else{
                            ++$temp_imgurl_i;
                            continue;
                        }
                        $imgurl[$temp_imgurl_i]['exhibitionsID'] = $exid;
                        model('maexhibits')->insert($imgurl[$temp_imgurl_i]);
                        ++$temp_imgurl_i;

                    }
                }

                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //on
    protected function Hxnart($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        //var_dump($urllist);die;
        //改进方案
        /*      $new_urllist = array();
              while(isset($urllist[$temp_i])){
                  $new_urllist = array_merge($new_urllist,$urllist[$temp_i]);
                  ++$temp_i;
              }

              $new_urllist = array_unique($new_urllist);
              $new_urllist = array_merge($new_urllist);

              var_dump($new_urllist);die;*/

        while(isset($urllist[$temp_i])){

            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            $temp_i_i = 0;
            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            $detailsInfo = array();
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);

                $pos = mb_strpos($contents,'white_title">');
                $contents = mb_substr($contents,$pos+mb_strlen('white_title">'));

                $pos = mb_strpos($contents,'img src="');
                $contents = mb_substr($contents,$pos + mb_strlen('img src="'));
                $pos = mb_strpos($contents,'"');

                $detailsInfo['pagehomeimgurl'] = $url.'/'.mb_substr($contents,0,$pos);

                $pos = mb_strpos($contents,'introduceblack2_title">');
                $contents = mb_substr($contents,$pos + mb_strlen('introduceblack2_title">'));
                $pos = mb_strpos($contents,'</table');
                $detailsInfo['address'] = '何香凝美术馆';
                $detailsInfo['organizers'] = '何香凝美术馆';
                $detailsInfo['introduction'] = strip_tags(iconv($charset,'utf-8/TRANSLIT',mb_substr($contents,0,$pos)));

                $temp_content = $detailsInfo['introduction'];
                $posstart = mb_strpos($temp_content,'展 期：');
                $temp_content = mb_substr($temp_content,$pos +mb_strlen('展 期：'));
                $posstart = mb_strpos($temp_content,'<BR');
                $temp_time = iconv($charset,'utf-8/TRANSLIT',mb_substr($temp_content,0,$posstart));
                $detailsInfo['opentimestart'] = preg_replace('/(\\D)+/','-',explode('—',$temp_time)[0]);
                $detailsInfo['opentimeend'] = preg_replace('/(\\D)+/','-',explode('—',$temp_time)[1]);

                if(!is_dir(ROOT_PATH.'exhibits')) mkdir(ROOT_PATH.'exhibits');
                if(!is_dir(self::$mFilePath)) {
                    mkdir(self::$mFilePath);
                    chmod(self::$mFilePath,0777);
                }
                $path_temp = self::$mFilePath.date('Ymd');
                if(!is_dir($path_temp)){
                    mkdir($path_temp);
                    chmod($path_temp,0777);
                }

                $findbyname=model('maexhibitions')->find("name='".$detailsInfo['name']."'");
                if(!$findbyname) {
                    $detailsInfo['visittime'] = time();
                    $exid = model('maexhibitions')->insert($detailsInfo);

                    //$imgurl

                    $temp_imgurl_i = 0;
                    while(isset($imgurl[$temp_imgurl_i])) {

                        /*echo '$temp_i::',$temp_imgurl_i,'<br />';
                        echo $imgUrlList[$temp_imgurl_i]['imgurl'];
                        echo '<br />';*/

                        $imgpath = $this->saveImage($imgurl[$temp_imgurl_i]['imgurl']);
                        if ($imgpath === false) {
                            ++$temp_imgurl_i;
                            continue;
                        }
                        if($imgpath != '') {
                            $imgurl[$temp_imgurl_i]['imgpath'] = 'exhibits/' . date('Ymd') . '/' . $imgpath;
                        }else{
                            ++$temp_imgurl_i;
                            continue;
                        }
                        $imgurl[$temp_imgurl_i]['exhibitionsID'] = $exid;
                        model('maexhibits')->insert($imgurl[$temp_imgurl_i]);
                        ++$temp_imgurl_i;

                    }
                }

                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //on
    protected function Szamor($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            $detailsInfo = array();
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);

                $encode = mb_detect_encoding($contents, array('UTF-8','GB2312','GBK'));
                if($encode !== 'UTF-8'){
                    $contents = iconv($encode,'utf-8/TRANSLIT',$contents);
                }


                $pos = mb_strpos($contents,'doc_title">');
                $contents = mb_substr($contents,$pos +mb_strlen('doc_title">'));
                $pos = mb_strpos($contents,'</h1');
                $detailsInfo['name'] = mb_substr($contents,0,$pos);
                $contents = mb_substr($contents,$pos);

                $pos = mb_strpos($contents,'cont_bd">');
                $contents = mb_substr($contents,$pos+mb_strlen('cont_bd">'));

                $pos = mb_strpos($contents,'text-align:center;">');
                if(pos === false){
                    ++$temp_i_i;
                    continue;
                }
                $contents = mb_substr($contents,$pos+mb_strlen('text-align:center;">'));
                $pos = mb_strpos($contents,'div class="cont_hd mt20 hide">');
                $contents = mb_substr($contents,0,$pos -1);

                $posstart = mb_strpos($contents,'<img src="');
                if($posstart !== false) {
                    $temp_content = mb_substr($contents,$posstart+mb_strlen('<img src="'));
                    $posstart = mb_strpos($temp_content,'"');
                    $detailsInfo['pagehomeimgurl'] = $url.mb_substr($temp_content,0,$posstart);
                }
                $time_year = date('Y');
                $posstart = mb_strpos($contents,$time_year-1);
                if($posstart === false){
                    $posstart = mb_strpos($contents,$time_year);
                }
                if($posstart !== false){
                    $temp_content = mb_substr($contents,$posstart);
                    $posstart = mb_strpos($temp_content,'</span');
                    $time = mb_substr($temp_content,0,$posstart);
                    $time_start = preg_replace('/(\\D)+/','-',explode('至',$time)[0]);
                    $time_end = preg_replace('/(\\D)+/','-',explode('至',$time)[1]);

                    $pos_time = mb_strpos($time_start,'-');
                    if($pos_time == 0){
                        $time_start = mb_substr($time_start,1);
                    }
                    if(mb_strlen($time_end)>=4 && mb_strlen($time_end)<=6){
                        $time_end = explode('-',$time_start)[0].'-'.$time_end;
                    }
                    $detailsInfo['opentimestart'] = $time_start;
                    $detailsInfo['opentimeend'] = $time_end;
                }

                $detailsInfo['address'] = '深圳美术馆';
                $detailsInfo['introduction'] = strip_tags($contents);

                if(!is_dir(ROOT_PATH.'exhibits')) mkdir(ROOT_PATH.'exhibits');
                if(!is_dir(self::$mFilePath)) {
                    mkdir(self::$mFilePath);
                    chmod(self::$mFilePath,0777);
                }
                $path_temp = self::$mFilePath.date('Ymd');
                if(!is_dir($path_temp)){
                    mkdir($path_temp);
                    chmod($path_temp,0777);
                }

                $findbyname=model('maexhibitions')->find("name='".$detailsInfo['name']."'");
                if(!$findbyname) {
                    $detailsInfo['visittime'] = time();
                    $exid = model('maexhibitions')->insert($detailsInfo);

                    //$imgurl

                    $temp_imgurl_i = 0;
                    while(isset($imgurl[$temp_imgurl_i])) {

                        /*echo '$temp_i::',$temp_imgurl_i,'<br />';
                        echo $imgUrlList[$temp_imgurl_i]['imgurl'];
                        echo '<br />';*/

                        $imgpath = $this->saveImage($imgurl[$temp_imgurl_i]['imgurl']);
                        if ($imgpath === false) {
                            ++$temp_imgurl_i;
                            continue;
                        }
                        if($imgpath != '') {
                            $imgurl[$temp_imgurl_i]['imgpath'] = 'exhibits/' . date('Ymd') . '/' . $imgpath;
                        }else{
                            ++$temp_imgurl_i;
                            continue;
                        }
                        $imgurl[$temp_imgurl_i]['exhibitionsID'] = $exid;
                        model('maexhibits')->insert($imgurl[$temp_imgurl_i]);
                        ++$temp_imgurl_i;

                    }
                }

                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //on nothing worth to crawler
    protected function Sjzmsg($urllist,$path,$url,$websitename){
        if(self::$debug == false){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off now
    protected function Zzmsgc($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();

        //var_dump($urllist);die;

        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            //var_dump($urllist[$temp_i]);die;

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            $detailsInfo = array();
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);

                $encode = mb_detect_encoding($contents, array('UTF-8','GB2312','GBK'));
                if($encode !== 'UTF-8'){
                    $contents = iconv($encode,'utf-8/TRANSLIT',$contents);
                }

                $pos = mb_strpos($contents,'text-align: center">');
                if($pos === false){
                    ++$temp_i_i;
                    continue;
                }

                $contents = mb_substr($contents,$pos + mb_strlen('text-align: center">'));
                $pos = mb_strpos($contents,'src="');
                if($pos !== false) {
                    $contents = mb_substr($contents, $pos + mb_strlen('src="'));
                    $pos = mb_strpos($contents, '"');
                    $detailsInfo['pagehomeimgurl'] = $url . mb_substr($contents, 0, $pos);
                }
                $pos = mb_strpos($contents,'展览名称');
                if($pos === false){
                    ++$temp_i_i;
                    continue;
                }
                $contents = mb_substr($contents,$pos +mb_strlen('光辉岁月'));
                $posstart = mb_strpos($contents,'<br');
                $posend = mb_strpos($contents,'<p');
                $posstart > $posend?$pos = $posend:$pos = $posstart;

                $detailsInfo['name'] = strip_tags(mb_substr($contents,0,$pos));

                $zhanlanshijian = array('展览时间','展       期','展期','展    期','展        期');
                $zhanlanshijian_i = 0;
                $pos = mb_strpos($contents,$zhanlanshijian[$zhanlanshijian_i]);
                while($pos === false && isset($zhanlanshijian[$zhanlanshijian_i])){
                    $pos = mb_strpos($contents,$zhanlanshijian[$zhanlanshijian_i]);
                    ++$zhanlanshijian_i;
                }
                if($pos === false){
                    $detailsInfo['opentimestart'] = '';
                    $detailsInfo['opentimeend'] = '';
                }else{
                    $temp_content = mb_substr($contents,$pos+mb_strlen($zhanlanshijian[$zhanlanshijian_i-1]));
                    //2016年12月30日-----2017年1月3日
                    //2016年12月3日——12月6日
                    //2016年11月18日——11月20日
                    // 2016年12月3日&mdash;&mdash;12月6日
                    $temp_tags = array('-','—','&mdash;');
                    $posstart = mb_strpos($temp_content,'<br');
                    $posend = mb_strpos($temp_content,'<p');
                    $posstart > $posend?$posstart = $posend:$posstart = $posstart;
                    $temp_time = mb_substr($temp_content,0,$posstart);

                    $temp_tags_i = 0;
                    $posstart = '    ';





                }




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Hbmoac($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Wuhana($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Hucfms($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Jsmsgc($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Njshuh($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Zan8cn($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Liuhai($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Jingde($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Dlzsms($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Lnmuse($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Duolun($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Haipai($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Rockbu($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Qdmjms($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Tymsgc($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        // var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Zjamor($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        // var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Sansha($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        // var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Mcacaa($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        // var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Yidear($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Nmaorg($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        ///var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }
    //off
    protected function Kdmofa($urllist,$path,$url,$websitename){
        if(self::$debug == true){
            return 0;
        }
        //$urllist 本文件下所有链接，这里的urllist是二维数组，以满足多页使用
        //$path 本文件的目录（日期目录），这里的path是直达日期目录的，注意要进上级目录
        //下载所有详情页
        $path_temp = explode('/',$path)[0].'/'.explode('/',$path)[1];
        //echo 'path!!'.$path.'<br />';
        //var_dump($urllist);die;
        $temp_i = 0;
        $filename = array();
        while(isset($urllist[$temp_i])){
            $temp_i_i = 0;
            $urllist[$temp_i] = array_unique($urllist[$temp_i]);
            $urllist[$temp_i] = array_merge($urllist[$temp_i]);

            while (isset($urllist[$temp_i][$temp_i_i])) {
                $controller = A('Home/Webdownload');
                /*echo $urllist[$temp_i][$temp_i_i];
                echo '<br />';
                echo $path;
                die;*/
                $filename[$temp_i][$temp_i_i] = $controller->download($urllist[$temp_i][$temp_i_i], $path_temp);
                //var_dump($filename);die;
                ++$temp_i_i;
            }
            ++$temp_i;
        }
        //打开并处理详情页，详情页名字存在数组$filename中
        //var_dump($filename);
        $temp_i = 0;
        while(isset($filename[$temp_i])){
            $temp_i_i = 0;
            while (isset($filename[$temp_i][$temp_i_i])) {
                //得到完整path
                $path_details = $path . '/' . $filename[$temp_i][$temp_i_i];
                //取出内容
                $contents = $this->getDetailsContents($path_details);
                //获得页面编码存为charset   后续iconv
                $pos = mb_strpos($contents,'charset');
                $charset = mb_substr($contents,$pos+mb_strlen('charset='));
                $pos = mb_strpos($charset,'"');
                $charset = mb_substr($charset,0,$pos);




                ++$temp_i_i;
            }
            ++$temp_i;
        }
    }

    protected function getDetailsContents($path){
        $contents = file_get_contents($path);
        return $contents;
    }

    protected function saveImage($img_url){

        /*echo 'This is save Img:::';
        echo $img_url;
        echo '<br />';*/

        $folder = ROOT_PATH.'exhibits/';

        if(!is_dir($folder)){
            mkdir($folder,0777);
            //chmod($folder,0777);
        }
        $folder = $folder.date('Ymd').'/';
        if(!is_dir($folder)){
            mkdir($folder,0777);
            //chmod($folder,0777);
        }

        //echo 'url：',$img_url,'<br />';

        $pic_format = array('.bmp','.jpg','.tiff','.gif','.pcx','.tga','.exif','.jpeg','.png',
            '.fpx','.svg','.psd','.cdr','.pcd','.dxf','.ufo','.eps','.ai','.raw','.WMF');

        //echo 'saveImage:','<br />','imgurl:',$img_url,'<br />','path:',$folder,'<br />';
        $img_url = str_replace('\\','',$img_url);

        $end = explode(".", $img_url);
        $temp_i = 0;
        while(isset($end[$temp_i])){
            ++$temp_i;
        }
        $end = "." . $end[$temp_i-1];

        if(!in_array($end,$pic_format)){
            return false;
        }
        //echo 'url没问题','<br />';
        $ch = curl_init();
        //echo 'curl没问题','<br />';
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        //要头信息
        curl_setopt($ch,CURLOPT_HEADER,1);
        //不要正文
        curl_setopt($ch, CURLOPT_NOBODY, 1);

        curl_setopt($ch,CURLOPT_URL,$img_url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $contents = curl_exec($ch);
        //echo 'contents::',$contents,'<br />';

        /*$content_type = curl_getinfo($ch,CURLINFO_CONTENT_TYPE);

        echo $content_type;die;*/
        curl_close($ch);


        $pos = mb_stripos($contents,'200');
        if($pos === false){
            $pos = mb_strpos($contents,'OK');
            if($pos === false){
                return '';
            }
        }

        $pic_name = $this->utime() . rand(1111, 9999) . $end;

        //set_time_limit(8 * 60 * 60); //限制最大的执行时间
        $destination_folder = $folder; //文件下载保存目录
        $newfname = $destination_folder . $pic_name;//文件PATH

        //echo 'newfname:',$newfname,'<br />';

        $ch = curl_init();
        try{$fp = fopen($newfname,'wb');}catch(Exception $err){
            cpError::write($err->getMessage());
            return 0;}
        //echo 'fopen is ok!!';
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

        curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
        curl_setopt($ch,CURLOPT_URL,$img_url);
        curl_setopt($ch,CURLOPT_FILE,$fp);

        $result=curl_exec($ch);
        curl_close($ch);
        fclose($fp);

        //生成缩略图
        Image::thumb($newfname,$destination_folder.'64_'.$pic_name,'','640','640',6);


        /*$image = new \Think\Image();
        //echo $newfname;
        try{$image->open($newfname);}catch (Exception $err){return 0;}
        echo 'Thinkphp open is right!!!';
        // 按照原图的比例生成一个最大为150*150的缩略图并保存为thumb.jpg
        //echo $destination_folder.'64_'.$pic_name;die;
        try{$image->thumb(640, 640)->save($destination_folder.'64_'.$pic_name);}catch (Exception $err){return 0;}
        //echo 'Thinkphp thumb is right!!','<br />';
        //die;*/

        return $pic_name;
    }

    function utime()
    {
        return time();
    }


}